import * as api from "../../plugins/api.js"
import * as types from './mutation-types'

export const session = async function ({
  commit
}) {
  try {
    let data = await api.session()
    commit(types.SET_U, data)
  } catch (err) {
    throw (err)
  }
}

export const login = async function ({
  commit
}, datas) {
  try {
    let data = await api.asynclogin(datas)
    commit(types.SET_U, data)
    return data
  } catch (err) {
    throw (err)
  }
}

export const actiontopiccount = async function ({
  commit
}, datas) {
  try {
    let data = await api.asynctopiccount(datas)
    commit(types.SET_TOPICCOUNT, data)
    return data
  } catch (err) {
    throw (err)
  }
}

export const actionusertopic = async function ({
  commit
}, datas) {
  try {
    let data = await api.asyncgetusertopic(datas)
    commit(types.SET_USERTOPIC, data)
    return data
  } catch (err) {
    throw (err)
  }
}

export const actionusercollect = async function ({
  commit
}, datas) {
  try {
    let data = await api.asyncgetusercollect(datas)
    commit(types.SET_USERCOLLECT, data)
    return data
  } catch (err) {
    throw (err)
  }
}

export const actionuserreply = async function ({
  commit
}, datas) {
  try {
    let data = await api.asyncgetuserreply(datas)
    commit(types.SET_USERREPLY, data)
    return data
  } catch (err) {
    throw (err)
  }
}

export const actionuserreplyfabulous = async function ({
  commit
}, datas) {
  try {
    let data = await api.asyncgetuserreplyfabulous(datas)
    commit(types.SET_USERREPLYFABULOUS, data)
    return data
  } catch (err) {
    throw (err)
  }
}